package com.tg.app.activity.account;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tg.app.R;
import com.base.BaseActivity;
import com.appbase.custom.base.FeedBackInfo;


import java.util.List;

public class QuestionTypeActivity extends BaseActivity {

    public static final String KEY_TYPE="key_type";
    public static final String KEY_FEEDINFOLIST="key_feedinfolist";
    TextView typetv;
    LinearLayout typelayout;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//remove title bar  即隐藏标题栏
        setContentView(R.layout.activity_questiontype);
        hideActionBar();
        initView();
    }

    protected void initView(){
        findViewById(R.id.back_toolbar).setOnClickListener(new View.OnClickListener() {
            @Override

            public void onClick(View v) {
                finish();
            }
        });
        typetv=findViewById(R.id.typetv);
        typelayout=findViewById(R.id.typelayout);
        typetv.setText(getIntent().getStringExtra(KEY_TYPE));
        List<FeedBackInfo> infos=getIntent().getParcelableArrayListExtra(KEY_FEEDINFOLIST);
        for(final FeedBackInfo info:infos){
            @SuppressLint("InflateParams")
            RelativeLayout layout= (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.layout_question_item,null);
            LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            layout.setLayoutParams(params);
            TextView tv=layout.findViewById(R.id.tv);
            tv.setText(info.getTitle());
            typelayout.addView(layout);
            layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent=new Intent(QuestionTypeActivity.this,QuestionAnswerActivity.class);
                    intent.putExtra(QuestionAnswerActivity.KET_TITLE,getString(R.string.faq));
                    intent.putExtra(QuestionAnswerActivity.KEY_FEEDINFO,info);
                    startActivity(intent);
                }
            });
        }
    }

    public void doSubmit(View view){
        Intent intent = new Intent(this, FeedBackActivity.class);
        startActivity(intent);
    }
}
